/*
 *  scheduler.c
 *  pire2pireV1
 *
 *  Created by jihed kamkoum on 05/05/10.
 *  Copyright 2010 ENSEIRB. All rights reserved.
 *
 */

#include "scheduler.h"

void changer_ordo_priorite(pthread_t pid, int file, int prio) { 
	struct sched_param p1; 
	int res;
	/* changer la file d'ordo et la priorite d'une thread */ 
	p1.sched_priority=prio; 
	if ((res=pthread_setschedparam(pid, file, &p1))!=-1) {
		afficher_ordo_priorite(pid);
	}
}

void afficher_ordo_priorite(pthread_t pid) { 
	int ordo; 
	struct sched_param p1;
	printf ("\n Thread %d : (ordo =", pid);
	pthread_getschedparam(pid,&ordo, &p1);
	switch (ordo) {
		case SCHED_FIFO : printf(" SCHED_FIFO, ") ; break ;
		case SCHED_RR :	printf(" SCHED_RR, ") ; break ; 
		case SCHED_OTHER : printf("SCHED_OTHER, ") ;
	}
	printf ("priorite = %d )\n", p1.sched_priority);
}